import Vue from 'vue';
import Router from 'vue-router';
import account from './account';
import shStock from './shStock';
import hkStock from './hkStock';
import usStock from './usStock';
import quotation from './quotation';
import zixuan from './zixuan';
let admin_view = 
  [
    {
      path: "/",
      redirect: "/login"
    },
    {
      path: '/login',
      name: 'Login',
      meta: {
        title: 'm.login',
        keepAlive: false
      },
      component: resolve => require(['@/views/login'], resolve),
    }
  ]
Vue.use(Router)

var router= new Router({
  // mode: 'history',
  base: "/",
  routes: [
    ...admin_view,
    {
      path: '/home',
      name:"home",
      component: resolve => require(['@/views/Home'], resolve),
      meta: {
        title: 'm.Home',
        keepAlive: false,
      },
      children:[
        ...account,
        ...quotation,
        ...hkStock,
        ...usStock,
        ...shStock,
        ...zixuan
      ]
    },
  ]
})

// router.beforeEach((to, from, next) => {
//   document.title = '--';
//   if (to.path == '/news_info') {
//     next()
//   } else if (!sessionStorage.getItem('token') && to.path != '/') {
//     // next({ path: '/' });
//     next({
//         path: '/',
//         query: { 'lang':localStorage.getItem('lang')}
//     })
//   } else {
//     if (to.matched.length === 0 || delFun(to.path)==false) { //匹配前往的路由不存在
//        //判断此跳转路由的来源路由是否存在，存在的情况跳转到来源路由，否则跳转到404页面
//        next({
//         path:'/errorinfo',
//         query:{'url':from.path}
//       })
//     } else {
//       next(); //如果匹配到正确跳转
//     }
//   }
// });

export default router